package com.zc.im.register.controller;

import com.zc.im.common.vo.Result;
import com.zc.im.register.cache.RegisterCache;
import com.zc.im.register.loadbanacer.ConnectLoadBalancer;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.CuratorCache;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * Project：im
 * Date：2022-04-23
 * Time：17:20
 * Description：获取连接器
 *
 * @author ChallenZhang
 * @version 1.0
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class ConnectorController {

    private final RegisterCache registerCache;

    private final ConnectLoadBalancer connectLoadBalancer;

    @GetMapping("/")
    public Result<String> get() {
        return Result.success(connectLoadBalancer.getServer(registerCache.getList()));
    }

}
